package com.dg.dto;

import com.dg.common.Const;
import com.dg.pojo.Acl;
import com.dg.pojo.AclModule;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class AclDto {

    private Integer id;

    private String name;

    private String aclModuleId;

    private String url;

    private String type;

    private String status;

    private Integer seq;

    private String remark;

    public static AclDto adapter(Acl acl, AclModule aclModule){
        AclDto aclDto = new AclDto();
        BeanUtils.copyProperties(acl, aclDto);
        aclDto.setStatus(Const.StatusEnum.codeOf(acl.getStatus()).getValue());
        aclDto.setAclModuleId(aclModule.getName());
        aclDto.setType(Const.AclTypeEnum.codeOf(acl.getType()).getValue());
        return aclDto;
    }


}
